#####2013/01/22
##### lock&HideAttr


import maya.cmds as cmds

class LocakHideAttr():
    def lockUI(self):
        i = 'lockAttr'
        if cmds.window(i , ex = True):
            cmds.deleteUI(i)
    
        cmds.window(i,t = 'LockAttr_Tool')
        cmds.columnLayout( adjustableColumn=True )
        cmds.separator(h=5,style ='in')
        cmds.separator(h=5,style ='in')
        cmds.rowLayout( numberOfColumns=4, columnWidth4=(100, 100, 100,100),  columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (3, 'both', 0), (4, 'both', 0)] )
        cmds.columnLayout(columnAttach=('both', 5), rowSpacing=10, columnWidth=100 )
        cmds.checkBox('checkBoxTx', label='translateX')
        cmds.checkBox('checkBoxTy', label='translateY')
        cmds.checkBox('checkBoxTz', label='translateZ')
        cmds.button('buttonT01',l = 'AllTranslate',c = lambda *arge:self.TranT())
        cmds.button('buttonT02',l = 'UnTranslate',c=lambda *arge:self.UnTranT())
        cmds.setParent('..')
        cmds.columnLayout(columnAttach=('both', 5), rowSpacing=10, columnWidth=100 )
        cmds.checkBox('checkBoxRx', label='rotateX')
        cmds.checkBox('checkBoxRy', label='rotateY')
        cmds.checkBox('checkBoxRz', label='rotateZ')
        cmds.button('buttonR01',l = 'AllRotate',c=lambda *arge:self.RoT())
        cmds.button('buttonR02',l = 'UnRotate',c=lambda *arge:self.UnRoT())
        cmds.setParent('..')
        cmds.columnLayout(columnAttach=('both', 5), rowSpacing=10, columnWidth=100 )
        cmds.checkBox('checkBoxSx', label='scaleX')
        cmds.checkBox('checkBoxSy', label='scaleY')
        cmds.checkBox('checkBoxSz', label='scaleZ')
        cmds.button('buttonS01',l = 'AllScale',c=lambda *arge:self.ScT())
        cmds.button('buttonS02',l = 'UnScale',c=lambda *arge:self.UnScT())
        cmds.setParent('..')
        cmds.columnLayout(columnAttach=('both', 5), rowSpacing=10, columnWidth=100 )
        cmds.separator(style='none' )
        cmds.separator(style='none' )
        #cmds.separator(style='none' )
        cmds.checkBox('checkBoxVis', label='visibility',v =1)
        cmds.separator(style='none' )
    
    
        cmds.separator(style='none' )
        cmds.separator(style='none' )
        cmds.button('buttonVis',l = 'visibility',c=lambda *arge:self.VoT())
        cmds.button('buttonVis02',l = 'Unvisibility',c=lambda *arge:self.UnVoT())
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.separator(h=5,style ='in')
        cmds.separator(h=5,style ='in')
        cmds.button('LockHideAttr01',l = 'LockHideAttr',c=lambda *arge:self.lockAttr())
        cmds.separator(h=5,style ='in')
        cmds.button('UnLockHideAttr01',l = 'UnLockHideAttr',c=lambda *arge:self.unlockAttr())
        cmds.separator(h=5,style ='in')
        cmds.separator(h=5,style ='in')
        cmds.showWindow(i)
    
    
    def TranT(self):
        cmds.checkBox('checkBoxTx',e=1,v=1)
        cmds.checkBox('checkBoxTy',e=1,v=1)
        cmds.checkBox('checkBoxTz',e=1,v=1)
    def UnTranT(self):
        cmds.checkBox('checkBoxTx',e=1,v=0)
        cmds.checkBox('checkBoxTy',e=1,v=0)
        cmds.checkBox('checkBoxTz',e=1,v=0)
    def RoT(self):
        cmds.checkBox('checkBoxRx',e=1,v=1)
        cmds.checkBox('checkBoxRy',e=1,v=1)
        cmds.checkBox('checkBoxRz',e=1,v=1)
    def UnRoT(self):
        cmds.checkBox('checkBoxRx',e=1,v=0)
        cmds.checkBox('checkBoxRy',e=1,v=0)
        cmds.checkBox('checkBoxRz',e=1,v=0)
    
    def ScT(self):
        cmds.checkBox('checkBoxSx',e=1,v=1)
        cmds.checkBox('checkBoxSy',e=1,v=1)
        cmds.checkBox('checkBoxSz',e=1,v=1)
    def UnScT(self):
        cmds.checkBox('checkBoxSx',e=1,v=0)
        cmds.checkBox('checkBoxSy',e=1,v=0)
        cmds.checkBox('checkBoxSz',e=1,v=0)
    
    def VoT(self):
        cmds.checkBox('checkBoxVis',e=1,v=1)
    
    def UnVoT(self):
        cmds.checkBox('checkBoxVis',e=1,v=0)
    
    def checkAttr(self):
        grp = []
        checkBox01 = cmds.checkBox('checkBoxTx',q=True,v=True)
        checkBoxTx = cmds.checkBox('checkBoxTx',q=True,l=True)
        if checkBox01 == 1:
            grp.append(checkBoxTx)
        else :
            pass
    
        checkBox02 = cmds.checkBox('checkBoxTy',q=True,v=True)
        checkBoxTy = cmds.checkBox('checkBoxTy',q=True,l=True)
        if checkBox02 == 1:
            grp.append(checkBoxTy)
        else :
            pass
    
        checkBox03 = cmds.checkBox('checkBoxTz',q=True,v=True)
        checkBoxTz = cmds.checkBox('checkBoxTz',q=True,l=True)
        if checkBox03 == 1:
            grp.append(checkBoxTz)
        else :
            pass
    
        checkBox04 = cmds.checkBox('checkBoxRx',q=True,v=True)
        checkBoxRx = cmds.checkBox('checkBoxRx',q=True,l=True)
        if checkBox04 == 1:
            grp.append(checkBoxRx)
        else :
            pass
    
        checkBox05 = cmds.checkBox('checkBoxRy',q=True,v=True)
        checkBoxRy = cmds.checkBox('checkBoxRy',q=True,l=True)
        if checkBox05 == 1:
            grp.append(checkBoxRy)
        else :
            pass
    
        checkBox06 = cmds.checkBox('checkBoxRz',q=True,v=True)
        checkBoxRz = cmds.checkBox('checkBoxRz',q=True,l=True)
        if checkBox06 == 1:
            grp.append(checkBoxRz)
        else :
            pass
    
        checkBox07 = cmds.checkBox('checkBoxSx',q=True,v=True)
        checkBoxSx = cmds.checkBox('checkBoxSx',q=True,l=True)
        if checkBox07 == 1:
            grp.append(checkBoxSx)
        else :
            pass
    
        checkBox08 = cmds.checkBox('checkBoxSy',q=True,v=True)
        checkBoxSy = cmds.checkBox('checkBoxSy',q=True,l=True)
        if checkBox08 == 1:
            grp.append(checkBoxSy)
        else :
            pass
    
        checkBox09 = cmds.checkBox('checkBoxSz',q=True,v=True)
        checkBoxSz = cmds.checkBox('checkBoxSz',q=True,l=True)
        if checkBox09 == 1:
            grp.append(checkBoxSz)
        else :
            pass
    
        checkBox10= cmds.checkBox('checkBoxVis',q=True,v=True)
        checkBoxVis= cmds.checkBox('checkBoxVis',q=True,l=True)
        if checkBox10 == 1:
            grp.append(checkBoxVis)
        else :
            pass
    
        return grp
    
    def lockAttr(self):
        Sel = cmds.ls(sl =True)
        grp=self.checkAttr()
        for sl in Sel:
            for lo in range(len(grp)):
                cmds.setAttr(sl+'.'+grp[lo] , lock=True ,keyable = False ,channelBox = False)
    def unlockAttr(self):
        grp=self.checkAttr()
        Sel = cmds.ls(sl =True)
        for sl in Sel:
            for lo in range(len(grp)):
                cmds.setAttr(sl+'.'+grp[lo] , lock=False ,channelBox = True)
                cmds.setAttr(sl+'.'+grp[lo] ,keyable = True )
    
    #lockUI()
    
    